package com.bflow.api;

import com.bflow.api.bo.BflowRunInstanceBo;
import com.bflow.api.bo.BflowRunInstanceQueryParam;
import com.bflow.api.bo.ext.BflowUserBo;
import com.bflow.commons.bean.PageBean;
import com.bflow.commons.bean.PageResult;
import com.bflow.commons.exception.BizException;
import com.bflow.commons.po.BasePo;
import com.bflow.commons.service.IBaseService;

import java.io.Serializable;
import java.util.List;

/**
 * 功能：BflowRunInstance 流程实例-业务接口
 * 作者：haowen
 * 日期：2018-12-13
 */
public interface IBflowRunInstanceService<P extends BasePo, B extends Serializable> extends IBaseService<P, B> {

    /**
     * 开启流程
     * @param bflowRunInstanceBo
     * @throws BizException
     */
    void startProcess(BflowRunInstanceBo bflowRunInstanceBo) throws BizException;

    /**
     * 停止流程
     * @param instanceId 流程实例ID
     * @throws BizException
     */
    void stopProcess(String instanceId) throws BizException;

    /**
     * 停止流程
     * @param busiKey 业务KEY
     * @param busiId 业务ID
     * @param busiSubId 子业务ID
     * @throws BizException
     */
    void stopProcess(String busiKey, String busiId, String busiSubId) throws BizException;

    /**
     * 更新 业务数据
     * @param instanceBo
     * @throws BizException
     */
    void updateBizData(BflowRunInstanceBo instanceBo) throws BizException;

    /**
     * 根据业务信息 查找唯一 流程
     * @param busiKey 业务KEY
     * @param busiId  业务ID
     * @param busiSubId 子业务ID
     * @return
     * @throws BizException
     */
    BflowRunInstanceBo findByBsId(String busiKey, String busiId, String busiSubId) throws BizException;

    PageResult<BflowRunInstanceBo> findPage(BflowRunInstanceQueryParam queryParam, String busiKey);

    /**
     *插入流程实例数据
     * @param bo
     * @return
     * @throws BizException
     */
    String add(BflowRunInstanceBo bo) throws BizException;

    /**
     * 根据流程实例ID 获取
     * @param instanceId
     * @param userId
     * @param getRecords 获取记录
     * @return
     * @throws BizException
     */
    BflowRunInstanceBo get(String instanceId, String userId, boolean getRecords) throws BizException;

    /**
     * 获取 处理人列表
     * @param allActArray
     * @return
     */
    String[] getProccessUserIds(String[] allActArray);

    /**
     * 获取申请列表
     * @param startUid
     * @param processId
     * @return
     * @throws BizException
     */
    PageResult<BflowRunInstanceBo> getList(String startUid,String processId)throws BizException;

    /**
     * 流程回退至上一步骤
     * @param instancesId
     * @param user
     * @throws BizException
     */
    void backByInstanceId(String instancesId, BflowUserBo user)throws BizException;

}
